//
//  QLNiceChatModel.m
//  Nice
//
//  Created by huangyueqi on 2017/7/31.
//  Copyright © 2017年 sjyt. All rights reserved.
//

#import "QLNiceChatModel.h"

@implementation QLNiceChatModel

+ (instancetype)chatModelWithDict:(NSDictionary *)dict {
    
    QLNiceChatModel *model = [[QLNiceChatModel alloc] init];
    [model setValuesForKeysWithDictionary:dict];
    return model;
}

- (CGFloat)cellHeight {
    
    //message 只有一行时cell的高度
    CGFloat defultCellHeight = 81;
    CGFloat defultLabelHeight = 20;
    CGFloat maxWidth = [UIScreen mainScreen].bounds.size.width - 110;
    CGSize maxSize = CGSizeMake(maxWidth, MAXFLOAT);
    
    // 计算内容label的高度
    CGFloat messageHeight = [self.umsg boundingRectWithSize:maxSize options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:16.0f]} context:nil].size.height;
    if (messageHeight > defultLabelHeight) {
        defultCellHeight = defultCellHeight - defultLabelHeight + messageHeight;
    }
    return defultCellHeight;
}

@end
